var pageNum = 2;
var currentPipeName = "";//由地图传过来的管廊id
var currrentZoneName = "";//由地图传过来分区id
var pageZoneId = ''; //全局变量分区id
var fanLeft = 0 ; //左风机防火阀弹框remark值，0 默认为没有风机防火阀信息
var fanRight = 0 ; //右风机防火阀弹框remark值，0 默认为没有风机防火阀信息
// console.info(currentPipeName+","+currrentZoneName);

var todayDate = moment().startOf('day');
var YM = todayDate.format('YYYY-MM');
var orgTreeId = '';
var tree_dropdown_menu = $("#tree-choose-dropdown-menu"); //机构树下拉框
var stopNum = null;
//暂无数据
var defaultDataHtml = '<div class="block-default"><div class="block-default-data"></div><p class="block-default-text">暂无数据</p></div>';
let refreshDataInterval = null; //数据刷新计时器
// let deviceArr = [];// 防火阀联控数组
var refreshCount=1;


// 2021-08-26
var pageCabinType ="";//全局变量舱室cabinType

function resetFan2(devcode){    //门禁打开弹窗
    //提示弹框交互
    swal({
        title: '确定打开防火门吗？',
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'btn btn-success',
        cancelButtonClass: 'btn btn-danger',
        allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
        allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
        allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
        buttonsStyling: false
    }).then(function (isConfirm) {
        let value = isConfirm.value;

        if (value != undefined) {
            $.ajax({
                url: "/yyglEmergencyCommand/turnMj",
                async: false,
                type: "post",
                data: {
                    devcode: devcode,
                    flag: "打开",
                    status: 'KZ',
                    cmdStr: '0', //打开
                    crecord: 1
                },
                success: function (list) {

                }
            });

        } else {
            //取消
            swal(
                '已取消！',
            );
        }
    });
}




// 接收大屏分区点击指令，打开对应二维图
function monitorJump(curZoneId) {
    if(curZoneId == 408 || curZoneId == 409){
        curZoneId = 407;
    }

    openProfileLayer2d(1,curZoneId);
}

// var Request = {};
// Request = GetRequest();

/*$(function () {
    // getPipeGalleryAlarmList(1, false);
    // init('showVideo');
    //视频监控数据动态获取
    // getVideo();

    //begin:: 左上角菜单的tab切换-交互实现
    var $switch_tab = $("#selectionTabSwitch .sel--tab-switch");
    var $switch_tab_content = $('#selectedListPanel .sel--tab-panel');
    var tabIndex = 0;

    $switch_tab.click(function () {
        getPipeGalleryAlarmList(1, false);

        $('#selectedListPanel').show();
        $('#toggleSidebarBtn').attr("title", "收起");
        $('#toggleSidebarBtn .btn--icon-arrow').removeClass("la-angle-double-right").addClass("la-angle-double-left");

        $($switch_tab[tabIndex]).removeClass('sel--tab-switch-active');
        $($switch_tab_content[tabIndex]).removeClass('sel--tab-panel-active');
        tabIndex = $(this).index();
        $(this).addClass('sel--tab-switch-active');
        $($switch_tab_content[tabIndex]).addClass('sel--tab-panel-active');
    });
    //end:: 左上角菜单的tab切换-交互实现
});*/

/*//begin:: 侧边栏折叠收起
function toggleFoldingUpSidebar(thatObj) {
    var arrowBtn = $(thatObj).find(".btn--icon-arrow");

    if (arrowBtn.hasClass("la-angle-double-right")) {
        arrowBtn.removeClass("la-angle-double-right").addClass("la-angle-double-left");
        $(thatObj).attr("title", "收起");
        $('#selectedListPanel').show();
    } else {
        arrowBtn.removeClass("la-angle-double-left").addClass("la-angle-double-right");
        $(thatObj).attr("title", "展开");
        $('#selectedListPanel').hide();
        $('#selectedListDetailPanel').hide();
    }
}*/

//end:: 侧边栏折叠收起

/*//begin:: 关闭详情侧边栏
function closeSelectedListDetailPanel() {
    $('#selectedListDetailPanel').hide();
    $('#selectedVideoTitle').html("");
    //清空
    $('.video-camera-btn').removeClass("video-camera-btn-selected");


    // 如果当前有视频窗口存在
    if (oWebControl != null && wdStatus) {
        oWebControl.JS_HideWnd();   // 先让窗口隐藏，规避可能的插件窗口滞后于浏览器消失问题

        // 销毁插件
        oWebControl.JS_DestroyWnd().then(function () {
            //销毁成功
            // console.log("插件窗口销毁");
            wdStatus = false;
        }, function () {
        });
    }
}

//end:: 关闭详情侧边栏*/




//begin:: 二维浏览管廊剖面图层
//打开
function openProfileLayer2d(cabinType,zoneId) {
    //alert(cabinType+'===='+zoneId);
 /*   // 检测视频窗口是否存在,当二维地图视频窗口存在时,不得销毁插件。规避分区按钮点击带来的bug
    if ($('#modal2dVideoDialog').css("display") == "block") {
        $('#selectedListDetailPanel').hide();
        $('#selectedVideoTitle').html("");
        //清空
        $('.video-camera-btn').removeClass("video-camera-btn-selected");
    } else {
        //关闭左侧监控窗口,内含插件销毁方法
        closeSelectedListDetailPanel();
    }*/

    //更新全局变量pageCabinType
    pageCabinType = cabinType;
    //更新全局变量pageZoneId
    pageZoneId = zoneId;
    // console.log('此刻pageCabinType：', pageCabinType);
    // console.log('此刻pageZoneId：', pageZoneId);
    // 根据全局变量,获得舱室类型，再根据舱室类型，更新切换按钮的样式
    var curBtnCabinId = '#tab_btn' + pageCabinType;
    $(curBtnCabinId).addClass("tab-active").siblings('.tab-btn').removeClass("tab-active");
    // 根据全局变量,获得分区号，再根据分区序号，更新切换按钮的样式
    var curBtnDomId = '#room_btn' + pageZoneId;
    $(curBtnDomId).addClass("room-active").siblings('.room-btn').removeClass("room-active");

    //打开弹框
    $('#profileLayer2d').show();

    //综合仓、电力仓分区内容都清空
    $("#multipleBin_01").html("");
    $("#multipleBin_02").html("");
    $("#multipleBin_03").html("");
    $("#multipleBin_04").html("");
    $("#multipleBin_end").html("");

    $("#electricBin_01").html("");
    $("#electricBin_02").html("");
    $("#electricBin_03").html("");
    $("#electricBin_04").html("");
    $("#electricBin_end").html("");

    //动态加载舱室中层内设备
    queryMaxAndMin(cabinType,zoneId);


    //选中3、4分区/5、6分区的时候另一个也加选中的样式名
    if($('#room_group_1 .room-btn').eq(2).hasClass("room-active")){
        $('#room_group_1 .room-btn').eq(3).addClass("room-active");
    }else if($('#room_group_1 .room-btn').eq(3).hasClass("room-active")){
        $('#room_group_1 .room-btn').eq(2).addClass("room-active");
    }else if($('#room_group_1 .room-btn').eq(4).hasClass("room-active")){
        $('#room_group_1 .room-btn').eq(5).addClass("room-active");
    }else if($('#room_group_1 .room-btn').eq(5).hasClass("room-active")){
        $('#room_group_1 .room-btn').eq(4).addClass("room-active");
    }
   // 开启数据刷新
     if (refreshDataInterval == null) {

        refreshDataInterval = setInterval(function () {

             if(refreshCount<=15){  // 数据刷新函数 2020-12-03
                 refreshCount=refreshCount+5;
             }else{
                 //综合仓、电力仓分区内容都清空
                 $("#multipleBin_01").html("");
                 $("#multipleBin_02").html("");
                 $("#multipleBin_03").html("");
                 $("#multipleBin_04").html("");
                 $("#multipleBin_end").html("");

                 $("#electricBin_01").html("");
                 $("#electricBin_02").html("");
                 $("#electricBin_03").html("");
                 $("#electricBin_04").html("");
                 $("#electricBin_end").html("");
                 queryMaxAndMin(pageCabinType,pageZoneId);
             }
         }, 400000000);//4000
     }
}

//根据分区id查询舱室信息
//判断分区是开头还是结尾
var O2AlarmArr=[]; //氧浓度、温湿度告警数据

function queryMaxAndMin(cabinType,zoneId) {
    // console.log("cabinType:" + cabinType);
    // console.log("zoneId:" + zoneId);
    $.ajax({
        url: "/yyglEmergencyCommand/queryPicType",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "cabinType":cabinType,
            "zoneId":zoneId
        },
        success: function (data) {
            // console.log("背景底图:",data);
            queryCabinInfoByPicType(data.result);  //查询设备并渲染
            queryFireDoorByPicType(data.result);   //查询防火门并渲染
            $("[id^='multipleBin_']").hide();
            $("[id^='electricBin_']").hide();
            $("#"+data.result).show();
        }
    });
}

//根据底图查询舱室信息
function queryCabinInfoByPicType(picType){
    let apOnlineData=[];

    // 获取ap设备在线数据
    $.ajax({
        url: "/yyglEmergencyCommand/queryApOnlineData",
        type: "post",
        dataType: "json",
        async: false,
        data: {},
        success: function (data) {
            apOnlineData=data;
            console.log(apOnlineData);
        }
    });

    $.ajax({
        url: "/yyglEmergencyCommand/queryCabinInfoByPicType",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "picType":picType,
        },
        success: function (data) {
            // console.log("舱室:",data);
            for(i=0;i<data.length;i++){
                for(j=0;j<data[i].length;j++){
                    let cabinId=data[i][j]['resId']
                    $.ajax({
                        url: "/yyglEmergencyCommand/queryDeviceByCabinId",
                        type: "post",
                        dataType: "json",
                        async: false,
                        data: {
                            "cabinId":data[i][j]['resId'],
                        },
                        success: function (equipment) {
                            var location;   //用来表示左中右位置  默认右，两组数据时为左右，三组数据时为左右中，四组是3分区变电站区域有特殊的摄像头，用substation表示
                            var tier;       //用来表示inner/layer层   i=0>inner/i=1>layer
                            var html = "";
                            var doorNum=0;
                            if (i == 0) {
                                tier = "inner";
                                if(data[i].length < 3){
                                    if (j == 0) {
                                        location = "left";
                                    } else if (j == 1) {
                                        location = "right";
                                    }
                                }else if(data[i].length == 3){
                                    if (j == 0) {
                                        location = "left";
                                    } else if (j == 1) {
                                        location = "middle";
                                    } else if (j == 2) {
                                        location = "right";
                                    }
                                }
                            } else if (i == 1) {
                                tier = "layer";
                                if(data[i].length == 1){
                                    location = "right";
                                }else if (data[i].length == 2){
                                    if (j == 0) {
                                        location = "left";
                                    } else if (j == 1) {
                                        location = "right";
                                    }
                                }else if(data[i].length == 3){
                                    if (j == 0) {
                                        location = "left";
                                    } else if (j == 1) {
                                        location = "right";
                                    } else if (j == 2) {
                                        location = "middle";
                                    }
                                }else{
                                    if (j == 0) {
                                        location = "left";
                                    } else if (j == 1) {
                                        location = "right";
                                    } else if (j == 2) {
                                        location = "middle";
                                    }else{
                                        location = "substation";
                                    }
                                }
                            }
                            // console.log('层：'+tier+"----位置:"+location);
                           //console.log(tier+"层"+location+"位置设备列表:",equipment);
                            /*devtypeid设备类型Id
                            * 摄像机 104033  remark：0-枪机，1-半球机，2-球机
                            * 氧气探测仪  104027
                            * 电话 104041  104040
                            * 甲烷  104028
                            * 温湿度仪   104026
                            * 防火门   104075   （只渲染中层的防火门）
                            * 普通灯具 104017  || EPS应急电源 104094
                            * 排水泵 104045   ||  通风机104022  || 液压井盖 104093
                            * 感烟探测器 104014  ||  手动报警 104015  || 声光报警  104016  （中层不显示）
                            * 无线AP  104042  ||  双鉴探测仪 104038 ||  浮球液位计 104095 ||  防火阀 104023 ||  集水坑 104009
                            * 仓室编号    5    cabinId
                            * 风向-进风口    1    wind_in       垂直风
                            * 风向-出风口    2    wind_out      垂直风
                            * 水平风-向右    3    wind_flow_right      水平风
                            * 水平风-向左    4    wind_flow_left     水平风
                            * */
                            for (k=0;k<equipment.length;k++){
                                var DevTypeid = equipment[k].devtypeid; //设备类型Id
                                var layerDevId = equipment[k].devId; //中层内设备Id
                                var signalModel = equipment[k].signalModel;
                                var DevCode = equipment[k].devCode;
                                var innerBarCode=equipment[k].barCode; //舱室内风机、防火阀编号barCode
                                var DevRelativePositionClass = location + '_'+tier+'-' + equipment[k].iconsType + '-' + equipment[k].relativePosition;
                                // console.log("设备类型Id:"+DevTypeid+"-----组合class:",DevRelativePositionClass);
                                if (DevTypeid == 5) {//舱内仓室编号id  5  cabinId
                                    html += '<div class="cabinId-number-font '+tier+'-cabinId-font '+ location +'_'+tier+'-cabinId">'+equipment[k].remark+'</div>';
                                }
                                else if (DevTypeid == 1 || DevTypeid == 2) {     // 垂直风向-进风 1 wind_in  出风 2 wind_out
                                    html += '<div class="inner_wind-box ' + DevRelativePositionClass + '">\n' +
                                        '<div class="pl-icon-' + equipment[k].iconsType + '"></div>\n' +
                                        '</div>';
                                }
                                else if (DevTypeid == 3 || DevTypeid == 4) {     //水平风向-向右风 3 wind_flow_right 向左风 4 wind_flow_left
                                    html += '<div class="inner_wind_flow-box ' + DevRelativePositionClass + '">\n' +
                                        '<div class="pl-icon-' + equipment[k].iconsType + '"></div>\n' +
                                        '</div>';

                                    // 增加一条水平风向的风
                                    var addWindClass = location + '_'+tier+'-' + equipment[k].iconsType + '-0' + (parseInt(equipment[k].relativePosition)+1);
                                    html += '<div class="inner_wind_flow-box ' + addWindClass + '">\n' +
                                        '<div class="pl-icon-' + equipment[k].iconsType + '"></div>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104033){   //摄像机 104033  remark：0-枪机，1-半球机，2-球机
                                    if(equipment[k].remark == 0){
                                        if(equipment[k].areaCode == 0){  //朝左 需要添加icon-camera-transform
                                            html += '<div class="pl-icons--wrap '+DevRelativePositionClass+' icon-camera-transform">\n' +
                                                '<a onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')" class="pl-inner-icons pl-icons-camera" href="javascript:;" title="'+equipment[k].devName+'"></a>\n' +
                                                '</div>';
                                        }else{
                                            html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                                '<a onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')" class="pl-inner-icons pl-icons-camera" href="javascript:;" title="'+equipment[k].devName+'"></a>\n' +
                                                '</div>';
                                        }
                                    }else if (equipment[k].remark == "1"){
                                        DevRelativePositionClass = location + '_'+tier+'-ball_' + equipment[k].iconsType + '-' + equipment[k].relativePosition;
                                        html +='<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                            '<a onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')" class="pl-inner-icons pl-icons-ball_camera"  href="javascript:;" title="'+equipment[k].devName+'"></a>\n' +
                                            '</div>';
                                    }else if (equipment[k].remark == "2"){
                                        DevRelativePositionClass = location + '_'+tier+'-eye_' + equipment[k].iconsType + '-' + equipment[k].relativePosition;
                                        html +='<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                            '<a onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')" class="pl-inner-icons pl-icons-eye_camera"  href="javascript:;" title="'+equipment[k].devName+'"></a>\n' +
                                            '</div>';
                                    }
                                }
                                else if (DevTypeid == 104027){  //氧气探测仪  104027
                                    var status = "无";
                                    var devBgStatusClass = ""; //设备默认状态的class,有报警信息/通讯中断 即为红
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if (signalModel[q].signalType == 'O2') {
                                                status = signalModel[q].value + signalModel[q].valunit;
                                            }else if(signalModel[q].signalType == 'OT'){
                                                if (signalModel[q].value == "1") {
                                                    devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }
                                        }
                                    }
                                    if(equipment[k].almNum == 1){   //almNum为1，有报警信息
                                        devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+devBgStatusClass+' pl-icon-oxygen"' +
                                        '  href="javascript:;" title="'+equipment[k].nodeName+'"></a>\n' +
                                        '<div class="pl-inner-icons pl-icon-oxygen-tooltip"  href="javascript:;" title="'+equipment[k].nodeName+'">\n' +
                                        '<p>氧气：'+status+'</p>\n' +
                                        '</div>\n' +
                                        '</div>';
                                }
                                else if (DevTypeid == 104028){  //甲烷  104028
                                    var concentration = "无";
                                    var devBgStatusClass = ""; //设备默认状态的class,有报警信息/通讯中断 即为红
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if (signalModel[q].signalType == 'CH') {
                                                concentration = signalModel[q].value + signalModel[q].valunit;
                                            }else if(signalModel[q].signalType == 'CT'){
                                                if (signalModel[q].value == "1") {
                                                    devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }
                                        }
                                    }
                                    if(equipment[k].almNum == 1){   //almNum为1，有报警信息
                                        devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+devBgStatusClass+' pl-icon-methane"' +
                                        '  href="javascript:;" title="'+equipment[k].nodeName+'"></a>\n' +
                                        '<div class="pl-inner-icons pl-icon-oxygen-tooltip"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'">\n' +
                                        '<p>甲烷：'+concentration+'</p>\n' +
                                        '</div>\n' +
                                        '</div>';
                                }
                                else if (DevTypeid == 104026){  //温湿度仪   104026
                                    var wd = "无";
                                    var sd = "无";
                                    var devBgStatusClass = ""; //设备默认状态的class,有报警信息/通讯中断即为红
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if (signalModel[q].signalType == 'WS') {
                                                sd = signalModel[q].value + signalModel[q].valunit;
                                            } else if (signalModel[q].signalType == 'WD') {
                                                wd = signalModel[q].value + signalModel[q].valunit;
                                            } else if(signalModel[q].signalType == 'WT'){
                                                if (signalModel[q].value == "1") {
                                                    devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }
                                        }
                                    }
                                    if(equipment[k].almNum == 1){   //almNum为1，有报警信息
                                        devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+devBgStatusClass+' pl-icon-temperature_humidity"' +
                                    ' href="javascript:;" title="'+equipment[k].nodeName+'"></a>\n' +
                                        '<div class="pl-inner-icons pl-icons-temperature_humidity-tooltip " href="javascript:;" title="'+equipment[k].nodeName+'">\n' +
                                        '<p>温度：'+wd+'</p>\n' +
                                        '<p>湿度：'+sd+'</p>\n' +
                                        '</div>\n' +
                                        '</div>';
                                }
                                else if (DevTypeid == 104075){  //防火门   104075  另有接口,只渲染中层的防火门。侧开的门有2扇的时候，都在中间再加一扇侧开的
                                    if(tier == 'layer'){
                                        var state="";  //状态，默认关闭。打开的时候赋值 -open
                                        if(equipment[k].remark == "1"){  //侧面开
                                            doorNum++;
                                            // console.log(doorNum);
                                            var openSuffixClass='pl-icon-layer_fire_door-01'+state;
                                            if(picType == 'electricBin_02' && tier =='layer' && location =='middle'){
                                                if(equipment[k].relativePosition == '04'){
                                                    openSuffixClass='pl-icon-layer_fire_door-02'+state;
                                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                                        '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                                        '</div>';
                                                }else{
                                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                                        '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                                        '</div>';
                                                }
                                            }else{
                                                if(doorNum>1){  //超过一扇侧开门，加一静态测开门
                                                    DevRelativePositionClass = location + '_'+tier+'-' + equipment[k].iconsType + '-02';
                                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                                        '<a class="pl-inner-icons pl-icon-layer_fire_door-01"  href="javascript:;" title="防火门"></a>\n' +
                                                        '</div>';
                                                    DevRelativePositionClass = location + '_'+tier+'-' + equipment[k].iconsType + '-03';
                                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                                        '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                                        '</div>';
                                                }else{
                                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                                        '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                                        '</div>';
                                                }
                                            }
                                        }else{   //正开门
                                            var openSuffixClass='pl-icon-layer_fire_door-00'+state;
                                            html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                                '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                                ' title="'+equipment[k].nodeName+'"></a>\n' +
                                                '</div>';
                                        }
                                    }
                                }
                                else if (DevTypeid == 104017 || DevTypeid == 104019){  //普通灯具 104017  || EPS应急电源 104094
                                    var lightingName="普通";  //灯具上的标注
                                    var openSuffixClass='pl-icon-'+equipment[k].iconsType;  //默认关闭
                                    var title=equipment[k].nodeName+'关闭';
                                    if(DevTypeid == 104019){
                                        lightingName="应急";
                                    }
                                    //照明，根据“照明反馈”的value来判断灯的开关
                                    for (var q = 0; q < signalModel.length; q++){
                                        if (signalModel[q].signalType == 'ZA') { //照明反馈
                                            if(signalModel[q].value == 1){  //0关/1开
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-open';
                                                title=equipment[k].nodeName+'打开';
                                            }
                                        }
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+openSuffixClass+'" href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '<span class="lighting-font">'+lightingName+'</span>\n' +
                                        '</div>';
                                }
                                else if( DevTypeid == 104022 ){   //通风机
                                    var openSuffixClass='pl-icon-'+equipment[k].iconsType;
                                    var title=equipment[k].nodeName+'关闭';
                                    //通风机、防火阀 根据低速状态和高速状态的value来判断开关，有一为1即开
                                    for (var q = 0; q < signalModel.length; q++){
                                        if (signalModel[q].signalType == 'HA' ) { //低速状态/高速状态
                                            if(signalModel[q].value == 1){  //0关/1开
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-open';
                                                title=equipment[k].nodeName+'打开';
                                            }
                                        }
                                        else if(signalModel[q].signalType == 'FS'){
                                            if(signalModel[q].value == 1){  //0关/1开
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-fault';
                                                title=equipment[k].nodeName+'故障';
                                            }
                                        }
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons '+openSuffixClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+',\''+innerBarCode+'\')"  href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '</div>';
                                }
                                else if( DevTypeid == 104023){   //防火阀
                                    var openSuffixClass='pl-icon-'+equipment[k].iconsType;
                                    var title=equipment[k].nodeName+'关闭';
                                    //通风机、防火阀 根据低速状态和高速状态的value来判断开关，有一为1即开
                                    for (var q = 0; q < signalModel.length; q++){
                                        if (signalModel[q].signalType == 'HA' ) { //低速状态/高速状态
                                            if(signalModel[q].value == 1){  //0关/1开
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-open';
                                                title=equipment[k].nodeName+'打开';
                                            }
                                        }
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons '+openSuffixClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+',\''+innerBarCode+'\')"  href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '</div>';
                                }
                                else if( DevTypeid == 104045){   //排水泵
                                    var openSuffixClass='pl-icon-'+equipment[k].iconsType;
                                    var title=equipment[k].nodeName+'关闭';
                                    //排水泵,运行状态 SA  1开/0关;红-故障状态为1或者电源状态为1
                                    for (var q = 0; q < signalModel.length; q++){
                                        if (signalModel[q].signalType == 'SA') { //运行状态
                                            if(signalModel[q].value == 1){  //0关/1开
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-open';
                                                title=equipment[k].nodeName+'打开';
                                            }
                                        }
                                        if (signalModel[q].signalType == 'SF') { //电源状态
                                            if(signalModel[q].value == 0){
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-fault';
                                                title=equipment[k].nodeName+'报警';
                                                break;
                                            }
                                        }
                                        if ( signalModel[q].signalType == 'SD' ) { //故障状态
                                            if(signalModel[q].value == 1){
                                                openSuffixClass='pl-icon-'+equipment[k].iconsType+'-fault';
                                                title=equipment[k].nodeName+'报警';
                                                break;
                                            }
                                        }

                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons '+openSuffixClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+',\''+innerBarCode+'\')"  href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '</div>';
                                }
                                else if( DevTypeid == 104095 ){   //浮球液位计
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'" onclick="modal2dlayerBtnClick('+DevTypeid+',\''+innerBarCode+'\')"' +
                                        ' href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104093){   //有打开关闭状态的设备，包括  、井盖
                                    var state="open";  //状态，默认关闭
                                    if(state == 'open'){
                                        var openSuffixClass='pl-icon-'+equipment[k].iconsType+'-open';
                                        var title=equipment[k].nodeName+'打开';
                                    }else if(state == 'fault'){
                                        var openSuffixClass='pl-icon-'+equipment[k].iconsType+'-fault';
                                        var title=equipment[k].nodeName+'报警';
                                    }else{
                                        var openSuffixClass='pl-icon-'+equipment[k].iconsType;
                                        var title=equipment[k].nodeName+'关闭';
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104014 || DevTypeid == 104016 || DevTypeid == 104015){  //中层上的感烟探测器、声光报警、手动报警按钮不显示
                                    if(tier == "inner"){
                                        DevRelativePositionClass = location + '_'+tier+'-' + equipment[k].iconsType + '-00';
                                        html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                            '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                            ' title="'+equipment[k].nodeName+'"></a>\n' +
                                            '</div>';
                                    }
                                }
                                else if(DevTypeid == 104042){  //无线AP
                                    var devBgStatusClass = ""; //设备默认状态的class
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if(signalModel[q].signalType == 'AP'){   //无线AP状态  1离线，变红
                                                if (signalModel[q].value == "1") {
                                                    devBgStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }
                                        }
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+devBgStatusClass+' pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104038){  //双鉴探测仪
                                    var openSuffixClass=equipment[k].iconsType;  //默认关闭
                                    var title=equipment[k].nodeName;
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if (signalModel[q].signalType == '01' && signalModel[q].value == "1") { //防区报警
                                                openSuffixClass=equipment[k].iconsType+'-open';
                                                title=equipment[k].nodeName+'报警';
                                                break;
                                            }else if (signalModel[q].signalType == '02' && signalModel[q].value == "1") { //防区布防
                                                openSuffixClass=equipment[k].iconsType+'-Armed';
                                                title=equipment[k].nodeName+'布防';
                                            }
                                        }
                                    }
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons pl-icon-'+openSuffixClass+'"  href="javascript:;"' +
                                        ' title="'+title+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104009){   //集水坑
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '<div class="sump_number-font">集水坑：' + equipment[k].barCode + '</div>'+
                                        '</div>';
                                }
                                else if(DevTypeid == 104101){   // 诱导风机 104101
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 104041 || DevTypeid == 104040 ){   // 紧急电话副机  104041  光纤紧急电话主机 104040
                                    console.log(signalModel);
                                    var dianHuaStatusClass = ""; //设备默认状态的class
                                    if (signalModel != null) {
                                        for (var q = 0; q < signalModel.length; q++) {
                                            if(signalModel[q].signalType == 'RPH'){   //电话状态  2振铃 3摘机，变红
                                                if (signalModel[q].value == "2"||signalModel[q].value == "3") {
                                                    dianHuaStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }else if(signalModel[q].signalType == 'NEN'){
                                                if (signalModel[q].value == "1") {
                                                    dianHuaStatusClass = "icons-bgk-red"; //设备离线状态的class
                                                }
                                            }
                                        }
                                    }

                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'" onclick="modal2dlayerBtnClick('+DevTypeid+','+layerDevId+')">\n' +
                                        '<a class="pl-inner-icons '+dianHuaStatusClass+'  pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '</div>';
                                }
                                else if(DevTypeid == 6){// 人员定位 6
                                    let apOnlineBol = false;
                                    let length = 0;
                                    let title = 'title="在线人数：'+length+'人"></a>';
                                    let iconA =  '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+apOnlineBol+'"  href="javascript:;"';
                                    // 获取舱室对应的在线设备列表
                                    for(let u=0;u<apOnlineData.length;u++){
                                        if(apOnlineData[u].remark==cabinId){
                                            length = apOnlineData[u].value.replace("[","").replace("]","").split(",").length;
                                            apOnlineBol = true;
                                            title = 'title="在线人数：'+length+'人 分别为：'+apOnlineData[u].value.replace("[","").replace("]","").replaceAll("\"","")+'"></a>\n';
                                            iconA = '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'" onclick="openApOnlinePage(\''+apOnlineData[u].value.replace("[","").replace("]","").replaceAll("\"","")+'\','+length+')" href="javascript:;"'
                                        }
                                    }

                                    if(apOnlineBol){
                                        html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                            iconA+
                                            // ' title="'+equipment[k].nodeName+'"></a>\n' +
                                            title +
                                            '<div class="online_number-font">' + length + '</div>'+
                                            '</div>';
                                    }
                                }
                                /*else{
                                    html += '<div class="pl-icons--wrap '+DevRelativePositionClass+'">\n' +
                                        '<a class="pl-inner-icons pl-icon-'+equipment[k].iconsType+'"  href="javascript:;"' +
                                        ' title="'+equipment[k].nodeName+'"></a>\n' +
                                        '</div>';
                                }*/
                            }
                            // console.log("需要插入的id:"+id+"-----html:",html);
                            $("#"+picType).append(html);
                        }
                    })

                }
            }
        }
    });
}

// 设备弹窗详情
//DevTypeid用来判断类型，DevId表示设备id
function modal2dlayerBtnClick(DevTypeid, DevId){
    var barCode = DevId;
    console.log("打开弹窗类型"+DevTypeid+";id/barCode:"+DevId);

    // 每次点击设备弹出的弹窗默认回到tab1
    document.getElementById("li1").style.opacity=1;
    document.getElementById("li2").style.opacity=1;
    document.getElementById("li1").className="item-active";
    document.getElementById("con_one_1").style.opacity=1;
    document.getElementById("li2").className="";
    document.getElementById("con_one_2").style.opacity=0;

    if(DevTypeid == 104023 || DevTypeid == 104022 || DevTypeid == 104045 || DevTypeid == 104095){   //通风机/防火阀/排水泵/浮球液位计
        $("#con_one_1").html('');  //清空监测信息
        $('#con_one_2').hide();
        monitorTf(barCode,DevTypeid,"");
        $('#modal-2dlayer-dialog_equipment').show();
    }else if(DevTypeid == 104033){ //视频单独弹窗
        monitorVideo(DevId,DevTypeid);
        $('#modal-2dlayer-dialog_monitor').show();
    }else{
        $("#con_one_1").html('');  //清空监测信息
        $('#con_one_2').hide();
        // 设备详情tabcontent
        monitor(DevId,DevTypeid);
        $('#modal-2dlayer-dialog_equipment').show();
    }

    // 如果视频窗口已显示
    if ($('#modal-2dlayer-dialog_equipment').css("display") == "block") {
        $("#modal-2dlayer-dialog_monitor").css("top", "470px");
    }
}
var signalCodeData="";//全局变量，收集监测信息中设备signalCode数据
var signalTypeData="";//全局变量，收集监测信息中设备signalType数据

var remarks=0; //收集当前防区点击的风机、防火阀remark值
//监测信息
function monitor(devId,DevTypeid) {
    var html = "";
    var data = "";
    $.ajax({
        url: "/yyglEmergencyCommand/queryMonitor",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "id": devId
        },
        success: function (list) {
            //console.log('id：'+devId+'的设备详情',list);
            data = list;
        }
    });
    var devtypeid = DevTypeid;//设备类型
    if ( devtypeid == 104017 || devtypeid == 104019 ){   //照明类
        // $('#tab_one_2').show();
        // $('#tab_one_2').attr("name",devId);
        var status = "无信号";
        var time = "无";
        var checked = "";
        var ycjd_flag = "无信号";
        if (data[0].signalModel != null) {
            var model = data[0].signalModel;
            for (var i = 0; i < model.length; i++) {
                if (model[i].signalName == "照明反馈") {
                    if (model[i].value == 1) {
                        status = "开灯";
                        checked = "checked='checked'";
                    } else {
                        status = "关灯";
                    }
                    time = model[i].lastTime;
                }else if(model[i].signalName == "远程就地"){
                    if (model[i].value == 1) {
                        ycjd_flag = "远程";
                    }else{
                        ycjd_flag = "就地";
                    }
                }
            }
        }
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<p class=\"text-value-blue\" id=\"info1_2019081645729619\">" + status + " </p>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">远程/就地</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<p class=\"text-value-blue\" id=\"info1_2019081645729619\">" + ycjd_flag + " </p>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测时间</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<p>时间:&nbsp;<span class=\"text-value-blue\">" + time + "</span></p>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">操作</dt>\n" +
            "<div style=\"float:left;\">打开/关闭：</div>\n" +
            "<div class=\"desc-switch-btn\">\n" +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill\">\n" +
            "<input name=\"openOrCloseSwitchZM\" data-switch=\"true\" id=\"" +  data[0].devcode + "\" type=\"checkbox\"" + checked +
            "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
            "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
            "</span>\n" +
            "</div>\n"+
            "</dl>";
    }
    else if ( devtypeid == 104026){  //温湿度仪
        var status = "无信号";
        var time = "无";
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n"+
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n";
        if (data[0].signalModel != null) {
            var model = data[0].signalModel;
            for (var i = 0; i < model.length; i++) {
                if (model[i].signalType == "WD" || model[i].signalType == "WS") {
                    html += '<dd class="desc-info line-height33" style=\"white-space:nowrap\">' +
                        '<span class=\"text-span-left wid40\">' + model[i].signalName + ":</span><span class=\"text-value-blue text-span wid65\">" + model[i].value + "" +model[i].valunit
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue time-span\">" + model[i].time + '</span>'
                        +'<span><input class=\"HisCurve-input\" type=\"button\" id=\" '+ model[i].signalCode + '\"' +
                        ' value=\"历史曲线\"></span></dd>';
                }
                else if (model[i].signalType == "WT") {
                    var tdStatus="正常";
                    if(model[i].value==1){
                        tdStatus="中断";
                    }
                    html += '<dd class="desc-info line-height33">' +
                        '<span class=\"text-span-left wid60\">' + '通讯状态' + ":</span><span class=\"text-value-blue text-span-center wid45\">" + tdStatus + ""
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue time-span\">" + model[i].time + '</span></dd>';
                }

            }

        }
        html +="</dl>";;
        document.getElementById("li2").style.opacity=0; // 关闭历史操作栏显示
    }
    else if ( devtypeid == 104027){  //氧浓度
        var status = "无信号";
        var time = "无";
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n"+
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n";
        if (data[0].signalModel != null) {
            var model = data[0].signalModel;
            for (var i = 0; i < model.length; i++) {
                if (model[i].signalType == "O2") {
                    html += '<dd class="desc-info line-height33" style=\"white-space:nowrap\">' +
                        '<span class=\"text-span-left wid55\">' + model[i].signalName + ":</span><span" +
                        " class=\"text-value-blue text-span wid50\">" + model[i].value + "" +model[i].valunit
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue time-span\">" + model[i].time + '</span>'
                        +'<span><input class=\"HisCurve-input\" type=\"button\" id=\" '+ model[i].signalCode + '\"' +
                        ' value=\"历史曲线\"></span></dd>';
                }
                else if (model[i].signalType == "OT") {
                    var tdStatus="正常";
                    if(model[i].value==1){
                        tdStatus="中断";
                    }
                    html += '<dd class="desc-info line-height33">' +
                        '<span class=\"text-span-left wid60\">' + '通讯状态' + ":</span><span class=\"text-value-blue text-span-center wid45\">" + tdStatus + ""
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue" +
                        " time-span\">" + model[i].time + '</span></dd>';
                }

            }

        }
        html +="</dl>";;
        document.getElementById("li2").style.opacity=0; // 关闭历史操作栏显示
    }
    else if ( devtypeid == 104028){  //甲烷
        var status = "无信号";
        var time = "无";
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n"+
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n";
        if (data[0].signalModel != null) {
            var model = data[0].signalModel;
            for (var i = 0; i < model.length; i++) {
                if (model[i].signalType == "CH") {
                    html += '<dd class="desc-info line-height33" style=\"white-space:nowrap\">' +
                        '<span class=\"text-span-left wid55\">甲烷:</span><span' +
                        " class=\"text-value-blue text-span wid50\">" + model[i].value + "" +model[i].valunit
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue time-span\">" + model[i].time + '</span>'
                        +'<span><input class=\"HisCurve-input\" type=\"button\" id=\" '+ model[i].signalCode + '\"' +
                        ' value=\"历史曲线\"></span></dd>';
                }
                else if (model[i].signalType == "CT") {
                    var tdStatus="正常";
                    if(model[i].value==1){
                        tdStatus="中断";
                    }
                    html += '<dd class="desc-info line-height33">' +
                        '<span class=\"text-span-left wid60\">' + '通讯状态' + ":</span><span class=\"text-value-blue text-span-center wid45\">" + tdStatus + ""
                        + "</span><span class=\"time-span-left wid40\">" + "时间:</span><span class=\"text-value-blue" +
                        " time-span\">" + model[i].time + '</span></dd>';
                }

            }

        }
        html +="</dl>";;
        document.getElementById("li2").style.opacity=0; // 关闭历史操作栏显示
    }
    else if (devtypeid == 104042) {	//无线AP
        var status = "无信号";
        var time = "无";
        if (data[0].signalModel != null) {
            if (data[0].signalModel[0].value == "1") {
                status = "离线";
            } else {
                status = "在线";
            }
            time = data[0].signalModel[0].time;
        }
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<p class=\"text-value-blue\">" + status + " </p>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测时间</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<p>时间:&nbsp;<span class=\"text-value-blue\">" + time + "</span></p>\n" +
            "</dd>\n" +
            "</dl>";
    }
    else if (devtypeid == 104038) {  //双鉴探测器
        //除了双鉴，水泵，风机，其他不需要历史操作tab
        //$('#tab_one_2').show();
        //$('#tab_one_2').attr("name",devId);
        var signalName1 = '无信号';
        var signalName2 = '无信号';
        var signalName3 = '无信号';
        var signalName4 = '无信号';

        var signalTime1 = '无';
        var signalTime2 = '无';
        var signalTime3 = '无';
        var signalTime4 = '无';


        var signalModels = data[0].signalModel;
        if (data[0].signalModel != null) {
            for (var i = 0; i < data[0].signalModel.length; i++) {
                if ("01" == signalModels[i].signalType) {
                    if (signalModels[i].value == "0") {
                        signalName1 = '正常';
                        signalTime1 = signalModels[i].time;
                    } else if (signalModels[i].value == "1") {
                        signalName1 = '报警';
                        signalTime1 = signalModels[i].time;
                    }
                } else if ("02" == signalModels[i].signalType) {
                    if (signalModels[i].value == "1") {
                        signalName2 = '布防';
                        signalTime2 = signalModels[i].time;
                        var flagcheck = "checked='checked'";
                    } else if (signalModels[i].value == "0") {
                        signalName2 = '撤防';
                        signalTime2 = signalModels[i].time;
                        var flagcheck = " ";
                    }
                } else if ("03" == signalModels[i].signalType) {
                    if (signalModels[i].value == "0") {
                        signalName3 = '未准备';
                        signalTime3 = signalModels[i].time;
                    } else if (signalModels[i].value == "1") {
                        signalName3 = '已准备';
                        signalTime3 = signalModels[i].time;
                    }
                } else if ("04" == signalModels[i].signalType) {
                    if (signalModels[i].value == "0") {
                        signalName4 = '正常';
                        signalTime4 = signalModels[i].time;
                    } else if (signalModels[i].value == "1") {
                        signalName4 = '故障';
                        signalTime4 = signalModels[i].time;
                    }
                }
            }
        }
        html += '<dl class="monitoring-info-description">' +
            '<dt class="desc-title">设备名称</dt>' +
            '<dd class="desc-info"><span class="text-value-blue">' + data[0].devname + '</span></dd>' +
            '<dt class="desc-title m--margin-top-10">监测情况</dt>' +
            //signalName1+signalName2+signalName3+signalName4
            '<span class="desc-info"><span class="text-span-left wid70" id="signalName1_' + devId + '">防区报警:</span><span class="text-value-blue text-span wid50">' + signalName1 + '</span><span class="time-span-left">时间:</span><span class="text-value-blue time-span">' + signalTime1 + '</span></dd>' +
            '<dd class="desc-info"><span class="text-span-left wid70" id="signalName2_' + devId + '">防区状态:</span><span class="text-value-blue text-span wid50">' + signalName2 + '</span><span class="time-span-left">时间:</span><span class="text-value-blue time-span">' + signalTime2 + '</span></dd>' +
            '<dd class="desc-info"><span class="text-span-left wid70" id="signalName3_' + devId + '">主机状态:</span><span class="text-value-blue text-span wid50">' + signalName3 + '</span><span class="time-span-left">时间:</span><span class="text-value-blue time-span">' + signalTime3 + '</span></dd>' +
            // '<dd class="desc-info"><span class="text-span-left wid80" id="signalName4_' + devId + '">通讯状态:</span><span class="text-value-blue text-span wid50">' + signalName4 + '</span><span class="time-span-left">时间:</span><span class="text-value-blue time-span">' + signalTime4 + '</span></dd>' +
            '<dt class="desc-title m--margin-top-10">布防与撤防操作</dt>' +
            "<div class=\"tips-text\">\n" +
            "<i class=\"la la-exclamation-circle\"></i>\n" +
            "<span>注意：1.主机状态为已准备时才可操作布防功能；</span>\n" +
            "</div>\n" +
            '<dd class="desc-info">' +
            '<div class="desc-switch-btn">' +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill\">\n" +
            "<input id=\"" + data[0].devcode + "\" name=\"withdrawalOrDeploySwitch\" data-switch=\"true\" type=\"checkbox\"  " +flagcheck+
            "data-on-text=\"布防\"  data-off-text=\"撤防\"   data-handle-width=\"28\" " +
            "data-on-color=\"success\" data-off-color=\"danger\"  data-size=\"small\"> \n" +
            "</span>\n" +
            '</div>' +
            '</dd>' +
            '</dl>'+
            '<div id="defenseAndWithdrawalInfo" class="m--font-metal" style="display:none"></div>';
    }
    else if (data[0].devtypeid == 104075) { // 防火门禁
        var signalName1 = "测试";
        var time1 = new Date().Format("yyyy-MM-dd HH:mm:ss");
        var signalName2 = "正常";
        var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");
        var arr = data[0].signalModel;
        if (arr != null) {
            for (var i = 0; i < data[0].signalModel.length; i++) {
                if ("MJ" == arr[i].signalType) {
                    if (arr[i].value == "01") {
                        signalName1 = '关门';
                        signalTime1 = arr[i].time;
                    } else if (arr[i].value == "00") {
                        signalName1 = '开门';
                        signalTime1 = arr[i].time;
                    }else if(arr[i].value == "10"||arr[i].value == "11"){
                        signalName1 = '强制开';
                    }else if(arr[i].value == "21"||arr[i].value == "20"){
                        signalName1 = '强制关';
                    }
                }

            }  //for结束
        }else{
            var signalName1 = "获取失败";
            var signalName2 = "获取失败";
        }
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" + data[0].devname + "</span>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n" +
            '<dd class="desc-info"><span class="text-span-left wid70">门禁状态:</span><span class="text-value-blue text-span wid70">' + signalName1 + '</span><span class="time-span-left wid40">时间:</span><span class="text-value-blue  time-span">' + time1 + '</span></dd>' +
            '<dd class="desc-info"><span class="text-span-left wid70">故障状态:</span><span class="text-value-blue text-span wid70">' + signalName2 + '</span><span class="time-span-left wid40">时间:</span><span class="text-value-blue  time-span">' + time2 + '</span></dd>' +
            // '<dd class="desc-info"><span class="text-span-left wid70">动作状态:</span><span class="text-value-blue text-span wid60">' + signalName2 + '</span><span class="time-span-left wid40">时间:</spa
            '<dt class="desc-title m--margin-top-10">开门与关门操作</dt>' +
            "<div class=\"tips-text\">\n" +
            "<i class=\"la la-exclamation-circle\"></i>\n" +
            "<span>注意：1.门禁为非强制状态方可被远程控制；</span>\n" +
            "</div>\n" +
            "<dt class=\"desc-title m--margin-top-10\">操作</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-span-left wid70\">打开门禁:</span>" +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
            "<input class=\"emergency_escape-input\" name=\"resetFan2\"   onclick='resetFan2(\""+data[0].devcode+"\")'    type=\"button\"  id=\"" + data[0].devcode + "\"  value=\"打开\"/> \n" +
            "</span>\n" +
            "</dd>\n" +
            "</dl>";
    }

    else if (data[0].devtypeid == 104041 ||data[0].devtypeid == 104040 ) { // 电话
        var signalName1 = "测试";
        var time1 = new Date().Format("yyyy-MM-dd HH:mm:ss");
        var signalName2 = "测试";
        var time2 = new Date().Format("yyyy-MM-dd HH:mm:ss");
        var arr = data[0].signalModel;

        var yanse="";
        var yanse2="";
        if (arr != null) {
            for (var i = 0; i < data[0].signalModel.length; i++) {


                if ("RPH" == arr[i].signalType) {
                    if (arr[i].value == "1") {
                        signalName1 = '空闲';
                        signalTime1 = arr[i].time;
                    } else if (arr[i].value == "2") {
                        signalName1 = '振铃';
                        yanse='red'
                        signalTime1 = arr[i].time;
                    }else if(arr[i].value == "3"){
                        signalName1 = '摘机';
                        yanse='red'
                        signalTime1 = arr[i].time;
                    }
                }else if ("NEN" == arr[i].signalType) {
                    if (arr[i].value == "0") {
                        signalName2 = '正常';
                        signalTime2 = arr[i].time;
                    } else if (arr[i].value == "1") {
                        signalName2 = '故障';
                        yanse2='red'
                        signalTime2 = arr[i].time;
                    }
                }


            }  //for结束
        }else{
            var signalName1 = "获取失败";
            var signalName2 = "获取失败";
        }
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dt class=\"desc-title\">设备名称</dt>\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-value-blue\">" +"电话副机"+ arr[0].pointAddr + "</span>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title m--margin-top-10\">监测情况</dt>\n" +
            '<dd class="desc-info"><span class="text-span-left wid70">通讯状态:</span><span class="text-value-blue text-span wid70" style="color:' + yanse + ' " >' + signalName1 + '</span><span class="time-span-left wid40">时间:</span><span class="text-value-blue  time-span">' + time1 + '</span></dd>' +
            '<dd class="desc-info"><span class="text-span-left wid70">设备状态:</span><span class="text-value-blue text-span wid70" style="color:' + yanse2 + ' " >' + signalName2 + '</span><span class="time-span-left wid40">时间:</span><span class="text-value-blue  time-span">' + time2 + '</span></dd>' +
            // '<dd class="desc-info"><span class="text-span-left wid70">动作状态:</span><span class="text-value-blue text-span wid60">' + signalName2 + '</span><span class="time-span-left wid40">时间:</spa

            "</dl>";
    }


    //防火门
    $("#con_one_1").html(html);
    /********************防火门弹窗************************/




    $('[name="openOrCloseSwitchZM"]').bootstrapSwitch({
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName("openOrCloseSwitchZM");
            var devcode = obj[0].id;
            var curState = state;
            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                // console.log("原先是关闭的，现在是确认是否开启");
                //提示弹框交互
                swal({
                    title: '确定开启照明吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。1
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "打开照明",
                                status: 'ZD',
                                cmdStr: '1',
                                crecord: 1
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'ZD');
                                }, 4000);
//                    	intReload=setInterval(function(){
//                    		reloadLampOrManhole(devid);
//                    	}, 2000);
                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 5000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name="openOrCloseSwitchZM"]').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                });
            } else {
                // console.log("原先是开启的，现在是确认是否关闭");
                //提示弹框交互
                swal({
                    title: '确定关闭照明吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = false; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "关闭照明",
                                status: 'ZF',
                                cmdStr: '1',
                                crecord: 1
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'ZF');
                                }, 4000);
//                    	intReload=setInterval(function(){
//                    		reloadLampOrManhole(devid);
//                    	}, 2000);
                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 5000);
                                swal(
                                    '已切换！',
                                );

                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name="openOrCloseSwitchZM"]').bootstrapSwitch("state", true);
                        swal(
                            '已取消！',
                        );
                    }
                });
            }
        }
    });//初始化按钮，照明开关按钮
    //分开初始化
    $('[name="withdrawalOrDeploySwitch"]').bootstrapSwitch({
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName("withdrawalOrDeploySwitch");
            var devcode = obj[0].id;
            var curState = state;
            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定切换为布防模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/invades",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "布防",
                                status: '03',
                                cmdStr: '1',
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                        swal(
                            '已切换！',
                        );
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name="withdrawalOrDeploySwitch"]').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定切换为撤防模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/invades",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "撤防",
                                status: '03',
                                cmdStr: '0',
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                        swal(
                            '已切换！',
                        );
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name="withdrawalOrDeploySwitch"]').bootstrapSwitch("state", true);

                        swal(
                            '已取消！',
                        );
                    }
                });
            }
        }


    });    //初始化按钮
}

function monitorVideo(devId,DevTypeid){
    $.ajax({
        url: "/yyglEmergencyCommand/queryMonitor",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "id": devId
        },
        success: function (data) {
            let macAddress=data[0].macAddress;
            if(macAddress!="" && macAddress!=undefined && macAddress!=null){
                // 获取摄像头编码进行播放
                openVideoPreviewPage(macAddress);
            }else{
               console.warn("该设备设备编码不存在!");
            }
        }
    });
}

// console.log('barCode：'+barCode+'的设备详情',list);
//监测信息---风机、防火阀 、水泵、液位----2021、09、09
function monitorTf(barCode,DevTypeid,remarks) {
    var html = "";
    var data = "";
    var num = 0; //给barCode数据编号初始值,用于水泵
    $.ajax({
        url: "/yyglEmergencyCommand/queryMonitorTf",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "barCode": barCode
        },
        success: function (list) {
          //  console.log('DevTypeid:' + DevTypeid + 'barCode：' + barCode + '的设备详情', list);
            data = list;
        }
    });
    //风机 104022
    if (DevTypeid == 104022 || DevTypeid == 104023) {
        for (var j = 0; j < data.length; j++) {
            if (data[j].devtypeid == "104022") {
                var ycjd_flag = "无信号";  //远程/就地状态
                var reset_flag = "无信号"; //风机故障信号
                var FA_checked = '';  //低速状态
                var FD_checked = '';  //高速状态
                var GL_checked = "";  //温湿度联动
                if (data[j].signalModel != null) {
                    for (var i = 0; i < data[j].signalModel.length; i++) {
                        if (data[j].signalModel[i].signalType == "FS") {//"风机故障";
                            if (data[j].signalModel[i].value == "1") {
                                reset_flag = "故障";
                            } else if (data[j].signalModel[i].value == "0") {
                                reset_flag = "正常";
                            }
                        }
                        if (data[j].signalModel[i].signalType == "FF") {//远程/就地
                            if (data[j].signalModel[i].value == "1") {
                                ycjd_flag = "远程";
                            }
                        }
                        if (data[j].signalModel[i].signalType == "FA") {  //低速状态
                            if (data[j].signalModel[i].value == 1) {
                                FA_checked = "checked='checked'";
                            }
                        }
                        if (data[j].signalModel[i].signalType == "FD") {  //高速状态
                            if (data[j].signalModel[i].value == 1) {
                                FD_checked = "checked='checked'";
                            }
                        }
                    }
                }
                html += '<dl class="monitoring-info-description" style="margin-bottom:0">' +
                    '<dd class="desc-info">\n' +
                    '<span class="text-span-left wid90" id=\"info1_2021090945729619\">监测情况:</span>\n' +
                    '<span class="text-value-blue text-span wid110">' + data[j].barCode + '</span>\n' +
                    '</dd>' +
                    "<dd class=\"desc-info\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info2_2021090945729619\">风机故障:</span>" +
                    "<span class=\"text-value-blue text-span wid110\">" + reset_flag + "</span>" +
                    "</dd>\n" +
                    "<dd class=\"desc-info\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info3_2021090945729619\">远程/就地:</span>" +
                    "<span class=\"text-value-blue text-span wid110\">" + ycjd_flag + "</span>" +
                    "</dd>\n" +
                    "<dd class=\"desc-info line-height33\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info4_2021090945729619\">低速状态:</span>" +
                    "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
                    "<input name=\"openOrCloseSwitchFanFA-" + data[j].barCode + "\"  id=\"FA_" + data[j].devcode + "\"" +
                    " title=\"" + data[j].barCode + "\"  data-switch=\"true\" type=\"checkbox\" " + FA_checked +
                    "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
                    "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
                    "</span>\n" +
                    "</dd>\n" +
                    "<dd class=\"desc-info line-height33\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info5_2021090945729619\">高速状态:</span>" +
                    "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
                    "<input name=\"openOrCloseSwitchFanFD-" + data[j].barCode + "\"  id=\"FD_" + data[j].devcode + "\"" +
                    " title=\"" + data[j].barCode + "\"  data-switch=\"true\" type=\"checkbox\" " + FD_checked +
                    "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
                    "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
                    "</span>\n" +
                    "</dd>\n" +
                    "<dd class=\"desc-info line-height33\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info6_2021090945729619\">温湿度联动:</span>" +
                    "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
                    "<input name=\"singleOrLinkageSwitchFan-" + data[j].barCode + "\"  id=\"" + data[j].devcode + "\"" +
                    " title=\"" + data[j].barCode + "\"  data-switch=\"true\" type=\"checkbox\" " + GL_checked +
                    "data-on-text=\"是\" data-handle-width=\"28\" data-off-text=\"否\" " +
                    "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
                    "</span>\n" +
                    "</dd>\n" +
                    '<dt class="desc-title content-info-main">\n' +
                    '<div class="tips-text">\n' +
                    '<i class="la la-exclamation-circle"></i>\n' +
                    '<span></span>\n' +
                    '</div>\n' +
                    '</dt>' +
                    '</dl>';

                var FAFan_name = "openOrCloseSwitchFanFA-" + data[j].barCode;//风机低速运行状态
                var FDFan_name = "openOrCloseSwitchFanFD-" + data[j].barCode;//风机高速运行状态
                var Fan_singleOrLinkage_name = "singleOrLinkageSwitchFan-" + data[j].barCode; // //单动联动切换
            } else {
                var FHF_checked = "";  //防火阀运行状态
                if (data[j].signalModel != null) {
                    for (var i = 0; i < data[j].signalModel.length; i++) {
                        if (data[j].signalModel[i].signalType == "HA") {
                            if (data[j].signalModel[i].value == "1") {
                                FHF_checked = "checked='checked'";
                            }
                        }
                    }
                }
                html += "<dl class=\"monitoring-info-description\">\n" +
                    "<dd class=\"desc-info\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info7_2021090945729619\">监测情况:</span>" +
                    "<span class=\"text-value-blue text-span wid110\">" + data[j].barCode + "</span>" +
                    "</dd>\n" +
                    "<dd class=\"desc-info line-height33\">\n" +
                    "<span class=\"text-span-left wid90\" id=\"info8_2021090945729619\">运行状态:</span>" +
                    "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
                    "<input name=\"openOrCloseSwitchFHF-" + data[j].barCode + "\"  id=\"FHF_" + data[j].devcode + "\"" +
                    "title=\"" + data[j].barCode + "\"  data-switch=\"true\" type=\"checkbox\"" + FHF_checked +
                    "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
                    "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
                    "</span>\n" +
                    "</dd>\n" +
                    /*"<dd class=\"desc-info timeout-info \"  id=\"RuntimerBox"+ remarks +"\">执行中\n" +
                    "<input class=\"setTimeout-input\" name=\"devRuntimer\" id=\"devRuntimer"+ remarks +"\"  type=\"button\" value=\"20\">\n" +
                    "秒...\n" +
                    "</dd>\n" +*/
                    "</dl>";
                var FHF_name = "openOrCloseSwitchFHF-" + data[j].barCode;

            }
        }
    }
    else if (DevTypeid == 104045 || DevTypeid == 104095) {
        // 水泵
        var gz_flag = ["正常", "正常"];   //水泵故障
        var ycjd_flag = ["就地", "就地"];  //远程/就地状态
        var dy_flag = ["正常", "正常"]    //电源状态
        var SA_checked = ["", ""];  //水泵状态
        var GL_checked = ["", ""];  //超高液位联动
        for (var j = 0; j < data.length - 1; j++) {
            if (data[j].signalModel != null) {
                for (var i = 0; i < data[j].signalModel.length; i++) {
                    if (data[j].signalModel[i].signalType == "GZ") {
                        if (data[j].signalModel[i].value == "0") {
                            gz_flag[j] = "正常";
                        } else if (data[j].signalModel[i].value == "1") {
                            gz_flag[j] = "故障";
                        } else {
                            gz_flag[j] = "无信号";
                        }
                    } else if (data[j].signalModel[i].signalType == "SG") {
                        if (data[j].signalModel[i].value == "1") {
                            ycjd_flag[j] = "远程";
                        }
                    } else if (data[j].signalModel[i].signalType == "SA") {
                        if (data[j].signalModel[i].value == "1") {
                            SA_checked[j] = "checked='checked'";
                        }
                    } else if (data[j].signalModel[i].signalType == "SF") {
                        if (data[j].signalModel[i].value == "0") {
                            dy_flag[j] = "异常";
                        }
                    } else if (data[j].signalModel[i].signalType == "SL") {
                        if (data[j].signalModel[i].value == "1") {
                            GL_checked[j] = "checked='checked'";
                        }
                    }
                }
            }
        }
        html += "<dl class=\"monitoring-info-description\" style=\"margin-bottom:0\">\n" +
            "<dd class=\"desc-info dd-line-height\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info1_2021090945729619\">监测情况:</span><span" +
            " class=\"text-value-blue text-span wid110\">" + data[num].barCode + "</span><span class=\"text-value-blue text-span wid110\">" + data[num + 1].barCode + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info dd-line-height\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info2_2021090945729619\">远程/就地:</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + ycjd_flag[num] + "</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + ycjd_flag[num + 1] + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info dd-line-height\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info3_2021090945729619\">水泵故障:</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + gz_flag[num] + "</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + gz_flag[num + 1] + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info dd-line-height\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info4_2021090945729619\">电源状态:</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + dy_flag[num] + "</span>" +
            "<span class=\"text-value-blue text-span wid110\">" + dy_flag[num + 1] + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info line-height33\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info5_2021090945729619\">水泵状态:</span>" +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
            "<input name=\"openOrCloseSwitchPump-" + data[num].barCode + "\"  id=\"SA_" + data[num].devcode + "\"" +
            " title=\"" + data[num].barCode + "\"  data-switch=\"true\" type=\"checkbox\" " + SA_checked[num] +
            "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
            "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
            "</span>\n" +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid110\">\n" +
            "<input name=\"openOrCloseSwitchPump2-" + data[num + 1].barCode + "\"  id=\"SA_" + data[num + 1].devcode +
            "\" title=\"" + data[num + 1].barCode + "\" data-switch=\"true\" type=\"checkbox\" " + SA_checked[num + 1] +
            "data-on-text=\"打开\" data-handle-width=\"28\" data-off-text=\"关闭\" " +
            "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
            "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info line-height33\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info6_2021090945729619\">超高液位联动:</span>" +
            "<span class=\"m-bootstrap-switch m-bootstrap-switch--pill wid220\">\n" +
            "<input name=\"singleOrLinkageSwitchPump-" + data[num].barCode + "\"  id=\"" + data[num].devcode + "\"   " +
            "title=\"" + data[num].barCode + "\"   org=\"" + data[num + 1].barCode + "\"  data-switch=\"true\" type=\"checkbox\" " + GL_checked[num] +
            "data-on-text=\"是\" data-handle-width=\"28\" data-off-text=\"否\" " +
            "data-on-color=\"success\" data-off-color=\"danger\" data-size=\"small\"> \n" +
            "</span>\n" +
            "</dd>\n" +
            "<dt class=\"desc-title content-info-main\">\n" +
            "<div class=\"tips-text\">\n" +
            "</div>\n" +
            "</dt>\n" +
            "</dl>";

        var Pump_name = "openOrCloseSwitchPump-" + data[num].barCode;//水泵运行状态
        var Pump2_name = "openOrCloseSwitchPump2-" + data[num + 1].barCode;//水泵2运行状态
        var Pump_singleOrLinkage_name = "singleOrLinkageSwitchPump-" + data[num].barCode; //初始化按钮 //单动联动切换

        //液位
        var status = "无信号";
        var time = "无";
        if (data[2].signalModel != null) {
            if (data[2].signalModel[0].value == "1") {
                status = "报警";
            } else {
                status = "正常";
            }
            time = data[2].signalModel[0].lastTime;
        }
        html += "<dl class=\"monitoring-info-description\">\n" +
            "<dd class=\"desc-info\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info7_2021090945729619\">设备名称:</span><span" +
            " class=\"text-value-blue text-span wid220\">" + data[2].devname + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info line-height33\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info8_2021090945729619\">监测情况:</span>" +
            "<span class=\"text-value-blue text-span wid220\">" + status + "</span>\n" +
            "</dd>\n" +
            "<dd class=\"desc-info line-height33\">\n" +
            "<span class=\"text-span-left wid90\" id=\"info9_2021090945729619\">监测时间:</span>" +
            "<span class=\"text-value-blue text-span wid220\">" + time + "</span>\n" +
            "</dd>\n" +
            "</dl>";
    }


    $("#con_one_1").html(html);
    var lock = false; //该伪锁用以解决按钮切换事件死循环问题
    // 开关
    // 风机低速运行状态

    $('[name="' + FAFan_name + '"]').bootstrapSwitch({    //初始化按钮
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(FAFan_name);
            var devcode = obj[0].id.replace("FA_", "");
            var title = obj[0].title;
            var curState = state;
            if (lock) {
                lock = false;
                return;
            }
            // console.log("barcode:",barcode)
            // singleOrLinkageSwitchFan 联动单动状态 true:联动 false:单动
            if (!$('[name=' + Fan_singleOrLinkage_name + ']').bootstrapSwitch('state')) {
                //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
                if (curState == true) {
                    //提示弹框交互
                    swal({
                        title: '确定高速运行' + title + '风机吗？',
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        confirmButtonClass: 'btn btn-success',
                        cancelButtonClass: 'btn btn-danger',
                        allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                        allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                        allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                        buttonsStyling: false
                    }).then(function (isConfirm) {
                        let value = isConfirm.value;

                        if (value != undefined) {
                            //确定开启，修改switch的状态(修改为true)
                            state = true; // true || false

                            $.ajax({
                                url: "/yyglEmergencyCommand/turnOn",
                                async: false,
                                type: "post",
                                data: {
                                    devcode: devcode,
                                    flag: "高速运行",
                                    status: 'FG',
                                    cmdStr: '1', //打开
                                    crecord: 1
                                },
                                success: function (list) {

                                    //把定时器赋值给一个变量
                                    var intCut1 = setInterval(function () {
                                        cut1(devcode, 'FG');
                                    }, 3000);

                                    //清除定时器
                                    setTimeout(function () {
                                        clearInterval(intCut1);
                                    }, 4000);
                                    swal(
                                        '已切换！',
                                    );
                                }
                            });
                        } else {
                            //取消，不修改switch的状态
                            state = !curState;
                            $('[name=' + FAFan_name + ']').bootstrapSwitch("state", false);
                            swal(
                                '已取消！',
                            );
                        }
                        //  $("#RuntimerBox"+remarks).css("display", "block");
                        var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                        clearTimeout(intCut2);
                    });
                } else {
                    //提示弹框交互
                    swal({
                        title: '确定关闭' + title + '风机吗？',
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        confirmButtonClass: 'btn btn-success',
                        cancelButtonClass: 'btn btn-danger',
                        allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                        allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                        allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                        buttonsStyling: false
                    }).then(function (isConfirm) {
                        let value = isConfirm.value;

                        if (value != undefined) {
                            //确定开启，修改switch的状态(修改为true)
                            state = true; // true || false
                            $.ajax({
                                url: "/yyglEmergencyCommand/turnOn",
                                async: false,
                                type: "post",
                                data: {
                                    devcode: devcode,
                                    flag: "关闭风机",
                                    status: 'FJ',
                                    cmdStr: '1',
                                    crecord: 1
                                },
                                success: function (list) {
                                    //把定时器赋值给一个变量
                                    var intCut1 = setInterval(function () {
                                        cut1(devcode, 'FJ');
                                    }, 3000);

                                    //清除定时器
                                    setTimeout(function () {
                                        clearInterval(intCut1);
                                    }, 4000);
                                    swal(
                                        '已切换！',
                                    );
                                }
                            });
                        } else {
                            //取消，不修改switch的状态
                            state = !curState;
                            $('[name=' + FAFan_name + ']').bootstrapSwitch("state", true);

                            swal(
                                '已取消！',
                            );
                        }
                        //   $("#RuntimerBox"+remarks).css("display", "block");
                        var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                        clearTimeout(intCut2);
                    });//初始化按钮
                }
            }
            // 非单动主状态
            else {

                swal(
                    '请将风机' + title + '设置为单动状态,再进行启停工作！',
                );

                lock = true;
                state = !curState;
                $('[name=' + FAFan_name + ']').bootstrapSwitch("state", state);
            }
        }
    });//风机低速运行状态
    // 风机高速运行状态
    $('[name="' + FDFan_name + '"]').bootstrapSwitch({    //初始化按钮
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(FDFan_name);
            var devcode = obj[0].id.replace("FD_", "");
            var title = obj[0].title;
            var curState = state;
            if (lock) {
                lock = false;
                return;
            }
            // console.log("barcode:",barcode)
            // singleOrLinkageSwitchFan 联动单动状态 true:联动 false:单动
            if (!$('[name=' + Fan_singleOrLinkage_name + ']').bootstrapSwitch('state')) {
                //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
                if (curState == true) {
                    //提示弹框交互
                    swal({
                        title: '确定高速运行' + title + '风机吗？',
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        confirmButtonClass: 'btn btn-success',
                        cancelButtonClass: 'btn btn-danger',
                        allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                        allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                        allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                        buttonsStyling: false
                    }).then(function (isConfirm) {
                        let value = isConfirm.value;

                        if (value != undefined) {
                            //确定开启，修改switch的状态(修改为true)
                            state = true; // true || false

                            $.ajax({
                                url: "/yyglEmergencyCommand/turnOn",
                                async: false,
                                type: "post",
                                data: {
                                    devcode: devcode,
                                    flag: "高速运行",
                                    status: 'FH',
                                    cmdStr: '1', //打开
                                    crecord: 1
                                },
                                success: function (list) {

                                    //把定时器赋值给一个变量
                                    var intCut1 = setInterval(function () {
                                        cut1(devcode, 'FH');
                                    }, 3000);

                                    //清除定时器
                                    setTimeout(function () {
                                        clearInterval(intCut1);
                                    }, 4000);
                                    swal(
                                        '已切换！',
                                    );
                                }
                            });
                        } else {
                            //取消，不修改switch的状态
                            state = !curState;
                            $('[name=' + FDFan_name + ']').bootstrapSwitch("state", false);
                            swal(
                                '已取消！',
                            );
                        }
                        //  $("#RuntimerBox"+remarks).css("display", "block");
                        var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                        clearTimeout(intCut2);
                    });
                } else {
                    //提示弹框交互
                    swal({
                        title: '确定关闭' + title + '风机吗？',
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        confirmButtonClass: 'btn btn-success',
                        cancelButtonClass: 'btn btn-danger',
                        allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                        allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                        allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                        buttonsStyling: false
                    }).then(function (isConfirm) {
                        let value = isConfirm.value;

                        if (value != undefined) {
                            //确定开启，修改switch的状态(修改为true)
                            state = true; // true || false
                            $.ajax({
                                url: "/yyglEmergencyCommand/turnOn",
                                async: false,
                                type: "post",
                                data: {
                                    devcode: devcode,
                                    flag: "关闭风机",
                                    status: 'FJ',
                                    cmdStr: '1',
                                    crecord: 1
                                },
                                success: function (list) {
                                    //把定时器赋值给一个变量
                                    var intCut1 = setInterval(function () {
                                        cut1(devcode, 'FJ');
                                    }, 3000);

                                    //清除定时器
                                    setTimeout(function () {
                                        clearInterval(intCut1);
                                    }, 4000);
                                    swal(
                                        '已切换！',
                                    );
                                }
                            });
                        } else {
                            //取消，不修改switch的状态
                            state = !curState;
                            $('[name=' + FDFan_name + ']').bootstrapSwitch("state", true);

                            swal(
                                '已取消！',
                            );
                        }
                        //   $("#RuntimerBox"+remarks).css("display", "block");
                        var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                        clearTimeout(intCut2);
                    });//初始化按钮
                }
            }
            // 非单动主状态
            else {

                swal(
                    '请将风机' + title + '设置为单动状态,再进行启停工作！',
                );

                lock = true;
                state = !curState;
                $('[name=' + FDFan_name + ']').bootstrapSwitch("state", state);
            }
        }
    });//风机高速运行状态

    // 风机单动联动切换
    $('[name=' + Fan_singleOrLinkage_name + ']').bootstrapSwitch({
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(Fan_singleOrLinkage_name);
            var devcode = obj[0].id;
            var title = obj[0].title;
            var curState = state;
            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定切换' + title + '联动模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        //     console.log(deviceArr[i]);
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "切换联动",
                                status: 'DL',
                                cmdStr: '1', //打开
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );

                            }
                        });

                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Fan_singleOrLinkage_name + ']').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定切换' + title + '单动模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "切换单动",
                                status: 'DL',
                                cmdStr: '0',
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );

                            }
                        });

                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Fan_singleOrLinkage_name + ']').bootstrapSwitch("state", true);

                        swal(
                            '已取消！',
                        );

                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            }
        }
    });//风机单动联动
    // 防火阀运行状态
    $('[name=' + FHF_name + ']').bootstrapSwitch({
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(FHF_name);
            var devcode = obj[0].id.replace("FHF_", "");
            var title = obj[0].title;
            var curState = state;
            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定开启' + title + '防火阀吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        //     console.log(deviceArr[i]);
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "打开防火阀",
                                status: 'HD',
                                cmdStr: '0', //打开
                                crecord: 0
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'HD');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });


                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + FHF_name + ']').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                    // $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定关闭' + title + '防火阀吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "关闭防火阀",
                                status: 'HS',
                                cmdStr: '1',
                                crecord: 0
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'HS');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });

                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + FHF_name + ']').bootstrapSwitch("state", true);
                        swal(
                            '已取消！',
                        );
                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            }

        }
    });//防火阀运行状态


    //水泵1运行状态
    $('[name="' + Pump_name + '"]').bootstrapSwitch({    //初始化按钮
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(Pump_name);
            var devcode = obj[0].id.replace("SA_", "");
            var title = obj[0].title;
            var curState = state;

            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定开启' + title + '水泵吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false

                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "打开水泵",
                                status: 'SH',
                                cmdStr: '1', //打开
                                crecord: 1
                            },
                            success: function (list) {

                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'SH');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump_name + ']').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定关闭' + title + '水泵吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "关闭水泵",
                                status: 'SJ',
                                cmdStr: '1',
                                crecord: 1
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'SJ');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump_name + ']').bootstrapSwitch("state", true);

                        swal(
                            '已取消！',
                        );
                    }
                    //   $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });//初始化按钮
            }

        }
    });//水泵1运行状态
    //水泵2运行状态
    $('[name="' + Pump2_name + '"]').bootstrapSwitch({    //初始化按钮
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(Pump2_name);
            var devcode = obj[0].id.replace("SA_", "");
            var title = obj[0].title;
            var curState = state;

            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定开启' + title + '水泵吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false

                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "打开水泵",
                                status: 'SH',
                                cmdStr: '1', //打开
                                crecord: 1
                            },
                            success: function (list) {

                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'SH');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump2_name + ']').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定关闭' + title + '水泵吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "关闭水泵",
                                status: 'SJ',
                                cmdStr: '1',
                                crecord: 1
                            },
                            success: function (list) {
                                //把定时器赋值给一个变量
                                var intCut1 = setInterval(function () {
                                    cut1(devcode, 'SJ');
                                }, 3000);

                                //清除定时器
                                setTimeout(function () {
                                    clearInterval(intCut1);
                                }, 4000);
                                swal(
                                    '已切换！',
                                );
                            }
                        });
                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump2_name + ']').bootstrapSwitch("state", true);

                        swal(
                            '已取消！',
                        );
                    }
                    //   $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });//初始化按钮
            }

        }
    });//水泵2运行状态
    // 水泵单动联动切换
    $('[name=' + Pump_singleOrLinkage_name + ']').bootstrapSwitch({
        onSwitchChange: function (event, state) {
            var obj = document.getElementsByName(Pump_singleOrLinkage_name);
            var devcode = obj[0].id;
            var title = obj[0].title;
            var curState = state;
            //先根据当前状态，再加载不同的弹框，确认后，再进行switch的状态切换
            if (curState == true) {
                //提示弹框交互
                swal({
                    title: '确定切换' + title + '联动模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;

                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        //     console.log(deviceArr[i]);
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "切换联动",
                                status: 'DL',
                                cmdStr: '1', //打开
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );

                            }
                        });

                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump_singleOrLinkage_name + ']').bootstrapSwitch("state", false);
                        swal(
                            '已取消！',
                        );
                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            } else {
                //提示弹框交互
                swal({
                    title: '确定切换' + title + '单动模式吗？',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    confirmButtonClass: 'btn btn-success',
                    cancelButtonClass: 'btn btn-danger',
                    allowOutsideClick: false, //true    如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
                    allowEscapeKey: false, //true   如果设置为false，用户无法通过按下Escape键关闭弹窗。
                    allowEnterKey: false, //true 如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
                    buttonsStyling: false
                }).then(function (isConfirm) {
                    let value = isConfirm.value;
                    if (value != undefined) {
                        //确定开启，修改switch的状态(修改为true)
                        state = true; // true || false
                        $.ajax({
                            url: "/yyglEmergencyCommand/turnOn",
                            async: false,
                            type: "post",
                            data: {
                                devcode: devcode,
                                flag: "切换单动",
                                status: 'DL',
                                cmdStr: '0',
                                crecord: 99
                            },
                            success: function (list) {
                                swal(
                                    '已切换！',
                                );

                            }
                        });

                    } else {
                        //取消，不修改switch的状态
                        state = !curState;
                        $('[name=' + Pump_singleOrLinkage_name + ']').bootstrapSwitch("state", true);

                        swal(
                            '已取消！',
                        );

                    }
                    //  $("#RuntimerBox"+remarks).css("display", "block");
                    var intCut2 = setTimeout(startCount(remarks), 1000);//1s后执行
                    clearTimeout(intCut2);
                });
            }
        }
    });//风机单动联动
}
//根据底图picType查询舱室内防火门设备
function queryFireDoorByPicType(picType) {
    $.ajax({
        url: "/yyglEmergencyCommand/queryFireDoor",
        type: "post",
        dataType: "json",
        async: false,
        data: {
            "picType": picType
        },
        success: function (door) {
            var doorHtml='';
            //console.log('防火门：', door);
            var closeStatus="";  //默认关闭，打开时为-open

            for (var i = 0; i < door.length; i++) {
                var doorLocation=['left','middle','right'];
                if(door.length == 2){
                    var doorLocation=['left','right'];
                }
                var innerDoorRelativePositionClass = doorLocation[i]+'_inner-fire_door-00';
                var openSuffixClass='pl-icon-inner_fire_door'+closeStatus;
                doorHtml +='<div class="pl-icons--wrap '+innerDoorRelativePositionClass+'">\n' +
                    '<a class="pl-inner-icons '+openSuffixClass+'"  href="javascript:;" title="防火门"></a>\n' +
                    '<span class="door-number-font">'+door[i].installAddress+'</span>     <!--门牌号-->\n' +
                    '</div>';
            }
            //单独添加，将防火门监控器设备div加入到对应底图div里
            $("#"+picType).append(doorHtml);

        }
    });
}


//二维底图打开时，根据舱室类型cabinType切换综合仓、电力仓事件（2021-08-25）
function ChangeCabinOnMapById(that, cTy){

    //每切换一次舱室，就清空数据刷新计时器
    clearInterval(refreshDataInterval);
    refreshDataInterval = null;
    refreshCount = 1;

    //更改舱室切换按钮的选中样式
    $(that).addClass("tab-active").siblings('.tab-btn').removeClass("tab-active");
    // console.log("cabinType:",cTy)
    // console.log("pageZoneId:",pageZoneId)
    //根据舱室ID打开对应舱室底图
    openProfileLayer2d(cTy,pageZoneId);
}




Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "H+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

//二维底图打开时，根据分区zoneId切换分区事件
function ChangeZoneOnMapById(that, zId) {
    // $('#modal-2dlayer-dialog-box').hide();
    // $('#modal-2dlayer-dialog-box-2').hide();
  //  FanFHFremarkArray.length = 0;
  //   fanLeft = 0 ;
  //   fanRight = 0;
    //每切换一次分区，就清空数据刷新计时器
    clearInterval(refreshDataInterval);
    refreshDataInterval = null;
    refreshCount = 1;

    //更改切换按钮的选中样式
    $(that).addClass("room-active").siblings('.room-btn').removeClass("room-active");


    //根据分区ID打开对应分区底图
    openProfileLayer2d(pageCabinType,zId);

    // 检测视频窗口是否存在
    if ($('#modal2dVideoDialog').css("display") == "block") {
        $("#modal2dVideoDialog").css("top", "20px");
        refreshPosition();
    }
}


//关闭二维管廊剖面图
function closeProfileLayer2d() {
    $('#profileLayer2d').hide();
    // stopId('showVideo_my-player');

    clearInterval(refreshDataInterval);
    refreshDataInterval = null;
    refreshCount=1;

    // //首、中间、尾端内容都清空
    // $("#pic_head").html("");
    // $("#pic_tail").html("");
    // $("#pic_middle_first").html("");
    // $("#pic_middle_later").html("");

    // 如果当前有视频窗口存在
    if(oWebControl != null && wdStatus){
        oWebControl.JS_HideWnd();   // 先让窗口隐藏，规避可能的插件窗口滞后于浏览器消失问题

        // 销毁插件
        oWebControl.JS_DestroyWnd().then(function () {
            //销毁成功
            // console.log("插件窗口销毁");
            wdStatus = false;
        }, function () {
        });
    }
}

//end:: 二维浏览管廊剖面图层


//关闭
var closeHisNum=0;  //  length-1
var closeHisNum2=0;
function closeModal2dlayerDialog() {
    // 检测视频窗口是否存在
    if ($('#modal2dVideoDialog').css("display") == "block") {
        $("#modal2dVideoDialog").css("top", "20px");
        refreshPosition();
    }


    $('#modal-2dlayer-dialog-box').hide();
    $('#modal-2dlayer-dialog-box-2').hide();
    //FanFHFremarkArray.length = 0;
    fanLeft = 0 ;
    fanRight = 0;
}
function closeModal2dlayerDialog2() {
    $('#modal-2dlayer-dialog-box-2').hide();
    closeHisNum2 = 2;
    var left_remark=$('#modal-2dlayer-dialog-box-2').attr('name');
  //  FanFHFremarkArray.splice(FanFHFremarkArray.indexOf(left_remark),1);
    fanLeft = 0 ;
    // console.log("关闭窗口2之后的FanFHFremarkArray：",FanFHFremarkArray)
}
//end:: 设备图标交互详情弹框（除摄像头外）

//begin:: 二维图摄像头设备图标交互详情弹框
//打开
function openModal2dVideoDialog() {
    $('#modal2dVideoDialog').show();
}

//二维摄像头弹窗关闭
function closeModal2dVideoDialog() {
    // 关闭视频预览
    stopPlay();
    curCameraCode="";
    $('#modal-2dlayer-dialog_monitor').hide();

    if ($('#modal-2dlayer-dialog_monitor').css("display") == "block") {
        $("#modal-2dlayer-dialog_monitor").css("top", "64px");
    }
}

//end:: 二维图摄像头设备图标交互详情弹框

//根据分区id查询舱室信息
//判断分区是开头还是结尾
var O2AlarmArr=[]; //氧浓度、温湿度告警数据


var cabinInfo;
var InterlayerInfo;
var gyAlarmLeft=false;
var sgAlarmLeft=false;
var sbAlarmLeft=false;
var gyAlarmRight=false;
var sgAlarmRight=false;
var sbAlarmRight=false;












//end:: 视频监控数据动态获取

//获取当前管廊警告信息,左侧展示
/*
1.page1:传入分页的页数;
2.clickFlag:传入是否点击的告警标签;
3.pipeName:管廊的id;
4.zoneName 分区的.
 */

//统计各告警级别信息数量
function countAlarmInfo(data) {
    //统计数组重复元素个数
    var arr = [];
    data.sort(function (a, b) {
        return a.almcls - b.almcls;
    });

    for (var i = 0; i < data.length;) {
        var count = 0;
        for (var j = i; j < data.length; j++) {
            if (data[i].almcls == data[j].almcls) {
                count++;
            }
        }
        arr.push({
            date: data[i].almcls,
            count: count
        });
        i += count;
    }

    $('#m_tabs_2_1 .btn-state-group .btn-state .state-info').html("<i></i>" + 0);

    for (var k = 0; k < arr.length; k++) {
        if (arr[k].count != 0) {
            switch (arr[k].date) {
                case "107601": {
                    $("#m_tabs_2_1 .btn-state-group .btn-state").find("[name='danger']").html("<i></i>" + arr[k].count);
                    break;
                }
                case "107602": {
                    $("#m_tabs_2_1 .btn-state-group .btn-state").find("[name='warn']").html("<i></i>" + arr[k].count);
                    break;
                }
                case "107603": {
                    $("#m_tabs_2_1 .btn-state-group .btn-state").find("[name='common']").html("<i></i>" + arr[k].count);
                    break;
                }
                case "107604": {
                    $("#m_tabs_2_1 .btn-state-group .btn-state").find("[name='inform']").html("<i></i>" + arr[k].count);
                    break;
                }
                default: {
                    break;
                }
            }

        }
    }
}

function Suppress(alarm_unique_id) {
    swal({
        title: '提示',
        text: "忽略告警",
        input: 'text',
        showCancelButton: true,
        allowOutsideClick: false, //如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
        allowEscapeKey: false, //如果设置为false，用户无法通过按下Escape键关闭弹窗。
        allowEnterKey: false, //如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
        confirmButtonText: '处理告警',
        cancelButtonText: '取消',
        inputPlaceholder: "填写处理结果",
        inputValidator: function (value) {
            return new Promise(function (resolve) {
                if (value) {
                    resolve();
                } else {
                    resolve('请填写处理结果!');
                }
            });
        }
    }).then(function (isConfirm) {
        //// console.log(isConfirm);
        if (isConfirm.dismiss === "cancel") {
            //点击取消按钮
            //console.info("cancel");
        } else {
            //console.info(isConfirm.value);
            $.ajax({
                url: "/yyglEmergencyCommand/Suppress",
                async: false,
                data: {
                    'alarmUniqueId': alarm_unique_id,
                    'result': isConfirm.value
                },
                type: "POST",
                success: function (data) {
                    // console.log(data);
                    if (data.result) {
                        swal({
                            title: "忽略告警成功",
                            type: "success",
                            showConfirmButton: false,
                            timer: 2000
                        }).then(function (result) {
                            getPipeGalleryAlarmList(1, false);
                        });

                    } else {
                        swal("提示", "忽略告警失败", "info");
                    }
                },
                error: function () {
                    swal("出错啦", "系统异常请稍后重试~", "error");
                }
            });
        }
    });
}


//解除告警-2020年3月5日 新增
function Relieve(alarm_unique_id) {
    swal({
        title: '提示',
        text: "解除告警",
        input: 'text',
        showCancelButton: true,
        allowOutsideClick: false, //如果设置为false，用户无法通过点击弹窗外部关闭弹窗。
        allowEscapeKey: false, //如果设置为false，用户无法通过按下Escape键关闭弹窗。
        allowEnterKey: false, //如果设置为false，用户无法通过按Enter键或空格键确认弹窗，除非手动使确认按钮获得焦点。
        confirmButtonText: '处理告警',
        cancelButtonText: '取消',
        inputPlaceholder: "填写处理结果",
        inputValidator: function (value) {
            return new Promise(function (resolve) {
                if (value) {
                    resolve();
                } else {
                    resolve('请填写处理结果!');
                }
            });
        }
    }).then(function (isConfirm) {
        //console.info(isConfirm);
        if (isConfirm.dismiss === "cancel") {
            //点击取消按钮
            //console.info("cancel");
        } else {
            //console.info(isConfirm.value);
            $.ajax({
                url: "/yyglEmergencyCommand/Relieve",
                async: false,
                data: {
                    'alarmUniqueId': alarm_unique_id,
                    'result': isConfirm.value
                },
                type: "POST",
                success: function (data) {
                    // console.log(data);
                    if (data.result) {
                        swal({
                            title: "解除告警成功",
                            type: "success",
                            showConfirmButton: false,
                            timer: 2000
                        }).then(function (result) {
                            getPipeGalleryAlarmList(1, false);
                        });
                    } else {
                        swal("提示", "解除告警失败", "info");
                    }
                },
                error: function () {
                    swal("出错啦", "系统异常请稍后重试~", "error");
                }
            });
        }
    });
}


//告警处理-警告等级标签点击事件
$('#m_tabs_2_1 .btn-state-group .btn-state').click(function () {
    //判断当前的被点击的事件源是否有btn-state-active，有就取消。没有就添加
    if ($(this).hasClass('btn-state-active')) {
        $(this).removeClass('btn-state-active');
    } else {
        $(this).addClass('btn-state-active');
    }

    //告警处理-更新左侧警告信息
    getPipeGalleryAlarmList(1, true, currentPipeName, currrentZoneName);
});


// window.onbeforeunload = function () {
//     stopId('showVideo_my-player');
//     stopId('modal2dVideoShowVideo_my-player');
// };

function checkOrder(alarmUniqueId) {
    $.ajax({
        url: "/yyglEmergencyCommand/checkOrder",
        type: "get",
        dataType: "json",
        data: {
            'alarmUniqueId': alarmUniqueId
        },
        success: function (data) {
            if (data.length > 0) {
                swal("提示", "该告警已派单！", "info");
            }
        }
    });
}

/**
 * 派单前通过spaceId获取管廊舱室分区
 * @param alarmUniqueId
 * @param ackFlag
 * @param spaceId
 * @returns
 */
function Dispatch(alarmUniqueId) {
    resetOrder();
    $.ajax({
        url: "/yyglEmergencyCommand/checkOrder",
        type: "get",
        dataType: "json",
        data: {
            'alarmUniqueId': alarmUniqueId
        },
        success: function (data) {
            if (data.length > 0) {
                swal("提示", "该告警已派单！", "info");
            } else {
                $('#m_datetimepicker_dateCN1').val("");
                $('#m_datetimepicker_dateCN2').val("");
                $('#ps').val("");
                $('#Orgnization').val("");
                $('#Qualification').val("");

                //if(ackFlag == 1 ){
                $.ajax({
                    url: "/yyglEmergencyCommand/getDispatch",
                    type: "get",
                    dataType: "json",
                    data: {
                        'alarmUniqueId': alarmUniqueId
                    },
                    success: function (data) {
                        $('#Dispatch').modal('show');//modal插件，手动打开模态框。
                        //$("#Dispatch").modal("toggle");// modal插件，手动切换模态框。
                        document.getElementById("alarm_unique_id").value = alarmUniqueId;
                        document.getElementById("pipe_name").value = data[0].groupName;
                        document.getElementById("pipe_id").value = data[0].pipeGalleryId;
                        document.getElementById("cabin_name").value = data[0].name;
                        document.getElementById("cabin_id").value = data[0].resId;
                        //document.getElementById("zone_name").value = data[0].zoneName;
                        //document.getElementById("zone_id").value = data[0].zoneId;
                    }
                });
            }
        }
    });

    //}
    /*else{
        swal({
            title: '警告!',
            text: "此条告警没有确认，无法进行当前操作!",
            type: 'warning',
            confirmButtonText: '确认'
        })
    }*/
}

//组织机构树
$(function () {
    //【页面组件部分】
    //机构选择的下拉框交互操作-选择
    $('#orgTreeChooseInputRole').click(function () {
        tree_dropdown_menu.toggle();
    });

    //机构选择的下拉框交互操作-点击下拉框外部时，关闭下拉框
    $(document).bind("click", function (e) {
        if ($(e.target).closest("#tree-choose-dropdown-menu").length == 0) {
            tree_dropdown_menu.hide();
        }
    });

    //【业务流程方面】
    //【step-1】下拉框中，组织机构树；先选择机构，然后筛选出部门
    var gl_org_tree = $("#gl_org_tree3"); //整个树obj
    //组织机构树
    $("#gl_org_tree3").jstree({
        "core": {
            "themes": {
                "responsive": false
            },
            // so that create works
            "check_callback": true,
            'data': {
                'url': '/userManagement/queryOrgRoot',
                'data': function (node) {
                    return {"id": node.id, "text": node.name}
                }
            }
        },
        "types": {
            "default": {
                "icon": "fa fa-folder m--font-warning"
            },
            "file": {
                "icon": "fa fa-file  m--font-warning"
            }
        },
        "state": {"key": "orgKey11", "opened": true}, //demo2 才生效 ； 保存当前树时要使用的键的字符串（如果在项目中使用多个树，则更改）。默认为jstree。
        "plugins": ["contextmenu", "state", "types", "wholerow"],
        /*"contextmenu":{
            "items":customMenu
        }*/
    }).on("load_node.jstree", function (e, data) {
        data.instance.clear_state(); //清除jstree保存的选中状态
        $('#gl_org_tree3').jstree().open_all();// 节点全部打开
        //默认选择第一个展示
        var inst_02 = data.instance;
        var obj_02 = inst_02.get_node(e.target.firstChild.firstChild.lastChild);
        inst_02.select_node(obj_02);
        //选择框值设定
        var org_name_02 = obj_02.text;
        $('#orgTreeChooseInputRole').val(org_name_02);

        //更改文件图标
        var nodes = data.node.children_d;
        for (var i in nodes) {
            var node = data.instance.get_node(nodes[i]);
            var level = node.id.split("_");
            if (level[2] == "N") {
                data.instance.set_type(node, 'file');
            }
        }
    }).on("changed.jstree", function (e, data) {
        if (data.selected.length) {
            var id = data.instance.get_node(data.selected[0]).id;
            var orgArr = id.split("_");
            var org_name = data.instance.get_node(data.selected[0]).text;
            tree_dropdown_menu.hide();
            $("#orgTreeChooseInputRole").val(org_name);
            //机构id
            orgTreeId = orgArr[1];
            /* var ref = $('#gl_org_tree3').jstree(true);//获得整个树
             var sel = ref.select_all(true);
            var eee =  $('#gl_org_tree3').jstree('select_all');
        //     var sel2 = ref.get_all_checked(true);
             // console.log("tree"+eee)*/

            $("#m_form_staffName").html("");

//     		var deptId=$('#distribute_dept').val();

            if (orgTreeId != '') {
                //$("select[name='staffName']").find("option").remove();
                $.ajax({
                    url: "/baseController/queryStaff",
                    async: false,
                    data: {"orgId": orgTreeId,},
                    type: "POST",
                    success: function (list) {
                        var data = list;
                        for (var i = 0; i < data.length; i++) {
                            var name = data[i].name;
                            var resId = data[i].resId;
                            var opt = new Option(name, resId);
                            $("select[name='staffName']").append(opt);
                        }
                        $('#m_form_staffName').selectpicker('refresh');
                        $('#m_form_staffName').selectpicker('render');

                    }
                });
            }
        }
    });
});

/**
 * 派单操作
 */
$("#submit").on("click", function () {
    var alarm_unique_id = $('#alarm_unique_id').val();
    var pipeId = $('#pipe_id').val();
    var cabinId = $('#cabin_id').val();
    //var zoneId = $('#zone_id').val();
    var ps = $('#ps').val();
    var select = document.getElementById("m_form_staffName");
    var str = [];
    for (i = 0; i < select.length; i++) {
        if (select.options[i].selected) {
            str.push(select[i].text);
        }
    }
    var Staffs = $('#m_form_staffName').val();

    var StaffsId = Staffs.join(",");
    if (orgTreeId == "" || orgTreeId.length == 0 || Staffs == "" || Staffs.length == 0) {
        swal("警告", "请将带*处填齐,不可为空!", "warning");
        return;
    }
    var startTime = $('#m_datetimepicker_dateCN1').val();
    var endTime = $('#m_datetimepicker_dateCN2').val();
    if (startTime == "" || startTime.length == 0 || endTime == "" || endTime.length == 0) {
        swal("警告", "请选择相应时间！", "warning");
        
    } else {
        //$('#mainForm').ajaxSubmit({
        var text = '';
        $.ajax({
            url: "/inspectionManagement/noticeUser",
            async: false,
            data: {"staffName": Staffs},
            traditional: true,
            type: "POST",
            success: function (list) {

                if (list.length > 0) {
                    for (var i = 0; i < list.length; i++) {
                        var data = list[i];
                        text += data[0].name + "：" + data[0].phoneNum + "  "
                    }
                }
            }
        });
        swal({
            title: '请联系以下接单人员',
            text: text,
            //	 type: 'warning',
            showCancelButton: true,
            confirmButtonText: '确认',
            cancelButtonText: '取消'
            //reverseButtons: true
        }).then(function (result) {
            if (result.value) {
                $.ajax({
                    url: '/yyglEmergencyCommand/Dispatch',
                    type: 'post',
                    async: false,
                    dataType: 'json',
                    data: {
                        'pipeId': pipeId,
                        'cabinId': cabinId,
                        //'zoneId' : zoneId,
                        "Orgnization": orgTreeId,
                        'ps': ps,
                        'startTime': startTime,
                        'endTime': endTime,
                        'Staffs': Staffs,
                        'alarmId': alarm_unique_id,
                        'StaffsName': str
                    },
                    traditional: true,
                    success: function (data) {
                        if (data.result) {
                            //swal("提示", "派单成功", "success");
                            swal({
                                title: "派单成功",
                                type: "success",
                                showConfirmButton: false,
                                timer: 2000
                            });
                            $("#Dispatch").modal("toggle");// modal插件，状态反转，关闭则显示，显示则关闭
                            datatableActive.reload();// 重新加载表格
                        } else {
                            //swal("提示", "派单失败", "error");
                            swal("提示", "派单失败", "info");
                        }
                    },
                    error: function () {
                        swal("出错啦", "系统异常请稍后重试~", "error");
                    },
                    clearForm: false,// 禁止清楚表单
                    resetForm: false // 禁止重置表单
                });
            }
        });
    }

});


function startTimeFlag() {
    var startTime = $("#m_datetimepicker_dateCN1").val();
    if (startTime == '' || startTime == undefined) {
        swal("警告!", "请先选择开始时间!", "warning");
        $("#m_datetimepicker_dateCN2").val("");
        
    }
}


// 重置按钮
$('#rest2').click(function () {
    $("#orgTreeChooseInputRole").val("");
    $('#m_datetimepicker_dateCN1').val("");
    $('#m_datetimepicker_dateCN2').val("");
    $("#m_form_staffName").empty();
    $("#m_form_staffName").selectpicker('refresh');//刷新
    $('#ps').val("");
});

function resetOrder() {
    $("#orgTreeChooseInputRole").val("");
    $('#m_datetimepicker_dateCN1').val("");
    $('#m_datetimepicker_dateCN2').val("");
    $("#m_form_staffName").empty();
    $("#m_form_staffName").selectpicker('refresh');//刷新
    $('#ps').val("");
}

//添加-X|关闭时重置
$('#close_modal').click(function () {
    $("#orgTreeChooseInputRole").val("");
    $('#m_datetimepicker_dateCN1').val("");
    $('#m_datetimepicker_dateCN2').val("");
    $("#m_form_staffName").empty();
    $("#m_form_staffName").selectpicker('refresh');//刷新
    $('#ps').val("");
});


// 等待指定元素加载完成后执行回调
jQuery.fn.wait = function (func, times, interval) {
    var _times = times || -1, //100次
        _interval = interval || 20, //20毫秒每次
        _self = this,
        _selector = this.selector, //选择器
        _iIntervalID; //定时器id
    if (this.length) { //如果已经获取到了，就直接执行函数
        func && func.call(this);
    } else {
        _iIntervalID = setInterval(function () {
            if (!_times) { //是0就退出
                clearInterval(_iIntervalID);
            }
            _times <= 0 || _times--; //如果是正数就 --
            _self = $(_selector); //再次选择
            if (_self.length) { //判断是否取到
                func && func.call(_self);
                clearInterval(_iIntervalID);
            }
        }, _interval);
    }
    return this;
};


function fontSize(res) {
    var docEl = document.documentElement,
        clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    if (!clientWidth) return;
    var fontSize = 100 * (clientWidth / 1920);
    return res * fontSize;
}

function closeEquipmentDialog(){
    $('#modal-2dlayer-dialog_equipment').hide();

    //修改视频窗口位置
    $("#modal-2dlayer-dialog_monitor").css("top", "64px");
}
function cut1(devcode, status) {
    $.ajax({
        url: "/yyglEmergencyCommand/turnOn",
        async: false,
        type: "post",
        data: {
            devcode: devcode,
            flag: false,
            status: status,
            cmdStr: '0',
            crecord: 0
        },
        success: function (list) {
            console.log("脉冲");
        }
    });
}
function startCount(remarks){
    // var timevalue = document.getElementById('devRuntimer'+remarks).value;
    // if(timevalue>1){
    //     // document.getElementById('RuntimerBox').style="display: inline-block";
    //     document.getElementById('devRuntimer'+remarks).value=timevalue-1;
    // }else {
    //     document.getElementById('RuntimerBox'+remarks).style="display: none";
    //     document.getElementById('devRuntimer'+remarks).value= 20;
    //     return false;
    // }
    // setTimeout("startCount("+remarks+")",1000);    //setTimeout是超时调用，使用递归模拟间歇调用
}

//感烟探测器 、手动报警器、无线ap在线设备的全部设备列表 设备交互事件-0816
function openApOnlinePage(apOnlineData,length) {
    //根据这2种设备类别，分别加载不同的设备列表到弹框中
    var contHtml = '';
    var iconsType="pl-icon-personnel_position";

    contHtml += '<p class="body-tittle">该区域在线人数：'+length + ' 人</p>\n' +
        '<ul class="equipment_info_list">';

    let macArr = apOnlineData.split(",");
    for(let i=0;i<macArr.length;i++){
        let userName = macArr[i].split("_")[1];
        let mac = macArr[i].split("_")[0];
        if(userName != "" && userName!=undefined && userName != null){
            contHtml += '<li>' +
                '<a class="pl-inner-icons '+iconsType + '-smallBg"></a>'+
                '<span class="'+iconsType+'-name">'+userName+'</span>' +
                '</li>';
        }else{
            contHtml += '<li>' +
                '<a class="pl-inner-icons '+iconsType + '-smallBg"></a>'+
                '<span class="'+iconsType+'-name">'+mac+'</span>' +
                '</li>';
        }
    }
    contHtml += '</ul>\n' +
        '</div>';

    $('#modal2dlayer_inner_equipment__body').html(contHtml);
    openModal2dlayerSpecialDevDialog();
}

function openModal2dlayerSpecialDevDialog() {
    $('#modal-2dlayer-dialog_inner_equipment-box-00').show();
}

//关闭
function closeModal2dlayerSpecialDevDialog() {
    $('#modal-2dlayer-dialog_inner_equipment-box-00').hide();
}